import 'dart:convert';

import 'package:huxiaodui/background_run/mqtt.dart';
import 'package:huxiaodui/store/store.dart';

class PushType{
  static String heart = "heart";
  static String position = "position";
}

class MQTTSend{


  static Future<void> service(String type,String data) async {

    Map<String,dynamic> msg = {};
    msg.addAll({
      "type":type,
      "data":data,
      "date":DateTime.now().millisecondsSinceEpoch
    });
    String? auth = await Store.auth.get();
    if(auth == null) return;

    MQTT().send(MyTopic.getService(auth), jsonEncode(msg));

  }

}
